export const $uploadFile = ((params = {}) => {
    return new Promise((resolve, reject) => {
        wx.showLoading({
          title: '上传中',
        })
        // 从本地缓存中获取 token
        const token = wx.getStorageSync('token');
        console.log("params is", params);
        wx.uploadFile({
          filePath: params.filePath,
          name: 'file',
          url: "http://127.0.0.1:8080/api/"+ params.url,
          header:{token:token},
          formData:params.data,
          success:(res) => {
              // 上传请求发送成功
              console.log("上传请求发送成功！", res);
              resolve(res)
          }, fail:(res) =>{
              // 上传请求发送失败
              console.log("上传请求发送失败", res);
              reject(res)
          }, complete:() => {
              wx.hideLoading()
          }
        })
    })
})